class AddAllFieldsToPatientDb < ActiveRecord::Migration
  def self.up
    add_column :patients, :hospice_branch_id, :integer, :null => false # link to branch table
    add_column :patients, :title, :string, :limit => 5
    add_column :patients, :initials, :string, :limit => 5
    add_column :patients, :res_address_1, :string, :limit => 30, :null => false
    add_column :patients, :res_address_2, :string, :limit => 30, :null => false
    add_column :patients, :res_address_suburb_id, :integer # lookup table on suburb
    add_column :patients, :res_address_post_code, :string, :limit=> 15, :null => false
    add_column :patients, :post_address_1, :string, :limit => 30
    add_column :patients, :post_address_2, :string, :limit => 30
    add_column :patients, :post_address_suburb_id, :integer # lookup table on suburb
    add_column :patients, :post_address_post_code, :string, :limit=> 15
    add_column :patients, :home_telephone_number, :string, :limit => 15
    add_column :patients, :cellphone_number, :string, :limit => 15
    add_column :patients, :identity_number, :string, :limit => 20
    add_column :patients, :gender, :string, :limit => 6, :null => false
    add_column :patients, :marital_status_id, :integer, :null => false # lookup table
    add_column :patients, :religion_id, :integer # lookup table
    add_column :patients, :medical_aid_id, :integer # lookup table
    add_column :patients, :medical_aid_number, :string, :limit => 20
    add_column :patients, :medical_insurance_id, :integer # lookup table
    add_column :patients, :medical_insurance_number, :string, :limit => 20
    add_column :patients, :undertaker_id, :integer # lookup table
    add_column :patients, :policy_number, :string, :limit => 20
    add_column :patients, :burial_type_id, :integer # lookup table
    add_column :patients, :employer_name, :string, :limit => 50
    add_column :patients, :employer_contact, :string, :limit => 50
    add_column :patients, :emp_address_1, :string, :limit => 30
    add_column :patients, :emp_address_2, :string, :limit => 30
    add_column :patients, :emp_address_suburb_id, :integer # lookup table on suburb
    add_column :patients, :emp_address_post_code, :string, :limit=> 15    
    add_column :patients, :employer_telephone, :string, :limit=> 15
    add_column :patients, :referral_date, :date, :null => false
    add_column :patients, :assessment_date, :date
    add_column :patients, :death_date, :date
    add_column :patients, :admission_date, :date
    add_column :patients, :referring_institute_id, :integer #lookup table
    add_column :patients, :referring_doctor_id, :integer #lookup table
    add_column :patients, :sister_id, :integer #lookup on homecare sisters
    add_column :patients, :social_worker_id, :integer #lookup on social workers
    add_column :patients, :patient_status_id, :integer #lookup
    add_column :patients, :death_location_id, :integer #lookup
    add_column :patients, :admission_reason_id, :integer #lookup
    add_column :patients, :hospice_doctor_id, :integer #lookup on hospice's doctors
  end

  def self.down
    remove_column :patients, :hospice_branch_id
    remove_column :patients, :title
    remove_column :patients, :initials
    remove_column :patients, :res_address_1
    remove_column :patients, :res_address_2
    remove_column :patients, :res_address_suburb_id
    remove_column :patients, :res_address_post_code
    remove_column :patients, :post_address_1
    remove_column :patients, :post_address_2
    remove_column :patients, :post_address_suburb_id
    remove_column :patients, :post_address_post_code
    remove_column :patients, :identity_number
    remove_column :patients, :gender
    remove_column :patients, :marital_status_id
    remove_column :patients, :religion_id
    remove_column :patients, :medical_aid_id
    remove_column :patients, :medical_aid_number
    remove_column :patients, :medical_insurance_id
    remove_column :patients, :medical_insurance_number
    remove_column :patients, :undertaker_id
    remove_column :patients, :policy_number
    remove_column :patients, :burial_type_id
    remove_column :patients, :employer_name
    remove_column :patients, :employer_contact
    remove_column :patients, :emp_address_1
    remove_column :patients, :emp_address_2
    remove_column :patients, :emp_address_suburb_id
    remove_column :patients, :emp_address_post_code
    remove_column :patients, :employer_telephone
    remove_column :patients, :referral_date
    remove_column :patients, :assessment_date
    remove_column :patients, :death_date
    remove_column :patients, :admission_date
    remove_column :patients, :referring_institute_id
    remove_column :patients, :referring_doctor_id
    remove_column :patients, :sister_id
    remove_column :patients, :social_worker_id
    remove_column :patients, :admission_reason_id
    remove_column :patients, :patient_status_id
    remove_column :patients, :death_location_id
    remove_column :patients, :hospice_doctor_id
  end
end
